<#include "../common/_header.htm">
<div id="hidebox" style="height:100%;width:100%">
    <button class="exportDetail">导出</button>
    <div class="box-body table-responsive">
        <table id="table" class="table text-nowrap"></table>
    </div>
</div>
<script>
    $(function() {

        /** 回去传值 **/
        var dialog = top.dialog.get(window);
        var data = dialog.data; // 获取对话框传递过来的数据
        $('#table').datagrid({
            url: '${ctx}/bill/stream/inaccountstatistics_detail',
            method: 'post',
            // toolbar: '#butt',
            iconCls: 'icon-save',
            queryParams:{//每次请求的参数
                accountRivalCard:data.accountRivalCard,
                accountRival:data.accountRival,
                cardList:data.cardList,
                timeVal:data.timeVal,
                casemanageId:data.caseId,
                timeType:data.timeType,
                contentAbstract:data.contentAbstract,
                sign:data.sign
            },

            pageSize:30,
            pageList:[30,50,100,150,200],
            pageNumber:1,//当前页号,
            //sortName:"TOTALMONEY",//排序列名称 设置后将向后台传送名为sort的post/get参数
            //sortOrder:"desc",//排序列升降序 设置后将向后台传送名为order的post/get参数

            loadMsg:"正在加载，请稍后",//加载数据时的提示信息
            emptyMsg:"暂无信息",//加载数据为空时的信息
            height:($(window).height())-50,
            rownumbers:true,//序号
            fitColumns: true,//使表格自适应页面宽度
            pagination: true,//是否分页
            singleSelect: true,
            columns:[[ //每一列的具体设置。
                {field:'ACCOUNT_BODY',title:'交易主体'},
                {field:'ACCOUNT_BODY_NUMBER',title:'交易主体账号'},
                {field:'ACCOUNT_BODY_CARD',title:'交易主体卡号'},
                {field:'ACCOUNT_RIVAL',title:'交易对手'},
                {field:'ACCOUNT_RIVAL_NUMBER',title:'交易对手账号'},
                {field:'ACCOUNT_RIVAL_CARD',title:'交易对手卡号'},
                {field:'SIGN',title:'交易类型',
                    formatter: function(value,row,index){ //当前值，当前的row，当前的索引
                       return value==0?'流入':'流出'
                    }
                },
                {field:'TRADE_DATE',title:'交易时间',
                    formatter: function(value,row,index){ //当前值，当前的row，当前的索引
                        if(value){
                            var date = new Date(value);
                            return formatDate(date, 'yyyy-MM-dd hh:mm:ss');
                        }else{
                            return '-';
                        }
                    }
                },
                {field:'ACCOUNT_MONEY',title:'交易金额', sortable : true},
                {field:'SURPLUS_MONEY',title:'交易后余额', sortable : true},
                {field:'CONTENT_ABSTRACT',title:'摘要'},
                {field:'ACCOUNT_RIVAL_BANK',title:'对手归属行'},
                {field:'ACCOUNT_BODY_BANK',title:'主体归属行'},
                {field:'INSTITUTION_NUMBER',title:'对方机构号'},
                {field:'TELLER_NUMBER',title:'柜员号'},
                {field:'REMARKS',title:'备注'}
            ]],
            onHeaderContextMenu: function(e, field){
                e.preventDefault();
                if (!cmenu){
                    createColumnMenu();
                }
                cmenu.menu('show', {
                    left:e.pageX,
                    top:e.pageY
                });
            }
        });
        $('button').on('click',function () {
            console.log(data);
            var xhr = new XMLHttpRequest();
            var url="${ctx}/bill/stream/inaccountExcel";
            xhr.open('POST', url, true);
            xhr.responseType = "blob";  // 返回类型blob
            // 定义请求完成的处理函数
            xhr.onload = function () {
                // 请求完成
                if (this.status === 200) {
                    var content = this.response;
                    var aTag = document.createElement('a');
                    var blob = new Blob([content]);
                    var headerName = xhr.getResponseHeader("Content-disposition");
                    var fileName = decodeURIComponent(headerName).substring(21);
                    aTag.download = fileName;
                    aTag.href = URL.createObjectURL(blob);
                    aTag.click();
                    URL.revokeObjectURL(blob);
                }
            };
            // 发送ajax请求
            var formdata=new FormData();
            formdata.append("accountRivalCard",data.accountRivalCard==undefined?"":data.accountRivalCard);
            formdata.append("accountRival",data.accountRival==undefined?"":data.accountRival);
            formdata.append("cardList",data.cardList==undefined?"":data.cardList);
            formdata.append("timeVal",data.timeVal==undefined?"":data.timeVal);
            formdata.append("casemanageId",data.caseId==undefined?"":data.caseId);
            formdata.append("sign",data.sign==undefined ?"":data.sign);
            formdata.append("timeType",data.timeType==undefined?"":data.timeType);
            formdata.append("contentAbstract",data.contentAbstract==undefined?"":data.contentAbstract);
            /*var formdata= "accountRivalCard="+data.accountRivalCard+"&accountRival="+data.accountRival+"&cardList="+data.cardList+"&timeVal="+data.timeVal
                +"&casemanageId="+data.caseId+"&sign="+data.sign+"&timeType="+data.timeType+"&contentAbstract="+data.contentAbstract;*/
            xhr.send(formdata);

        });
    });
</script>
<style>
    button.exportDetail {
        position: absolute;
        bottom: 0px;
        left: 50%;
        transform: translateX(-50%);
        background-color: #23B7E5;
        border-color: #23B7E5;
        width: 70px;
        height: 30px;
        color: #fff;
        border-color: transparent;
        cursor: pointer;
        border-radius: 4px;
    }
    #hidebox {
        top: 23px;
        left: 2%;
        border-radius: 5px;
        background-color:#fff;
        z-Index:9999;
        padding: 10px;
        overflow:hidden;
    }
    .box-body.table-responsive {
        height: 100%;
    }
</style>
</body>
</html>
